/*
 * MIT License
 *
 * Copyright (c) 2023 北京凯特伟业科技有限公司
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.je.ibatis.extension.metadata.model;

import com.je.ibatis.extension.metadata.IdType;

/**
 * Id
 *
 * @author wangmm@ketr.com.cn
 * @date 2019/11/21
 */
public class Id extends BaseMeta {

    /**
     * 列名
     */
    private String code;
    /**
     * AUTO,UUID,默认uuid
     */
    private IdType type = IdType.UUID;
    /**
     * generatorType=AUTO时使用，自增序列名称(适配Oracle等不支持主键自增策略的数据库)
     */
    private String incrementerName;
    /**
     * 自定义sql
     */
    private String sql;

    public Id(String code, IdType type, String incrementerName, String sql) {
        this.code = code;
        this.type = type;
        this.incrementerName = incrementerName;
        this.sql = sql;
    }

    public String getCode() {
        return code;
    }

    public Id setCode(String code) {
        this.code = code;
        return this;
    }

    public IdType getType() {
        return type;
    }

    public Id setType(IdType type) {
        this.type = type;
        return this;
    }

    public Id setType(String type) {
        this.type = IdType.getIdType(type);
        return this;
    }

    public String getIncrementerName() {
        return incrementerName;
    }

    public Id setIncrementerName(String incrementerName) {
        this.incrementerName = incrementerName;
        return this;
    }

    public String getSql() {
        return sql;
    }

    public Id setSql(String sql) {
        this.sql = sql;
        return this;
    }

    @Override
    public String toString() {
        return "Id{" +
                "code='" + code + '\'' +
                ", type=" + type +
                ", incrementerName='" + incrementerName + '\'' +
                '}';
    }
}